/* GPLv2 License
 *
 * Copyright (C) 2016-2018 Lixing Ding <ding.lixing@gmail.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 **/

#ifndef __LANG_TYPE_BUFFER_INC__
#define __LANG_TYPE_BUFFER_INC__

/*
#include "def.h"

#include "val.h"
#include "env.h"

#define MAGIC_BUFFER        (MAGIC_BASE + 13)
typedef struct type_buffer_t {
    uint8_t  magic;
    uint8_t  age;
    uint16_t len;
    uint8_t  buf[0];
} type_buffer_t;

static inline
int buffer_mem_space(type_buffer_t *buf) {
    return SIZE_ALIGN(sizeof(type_buffer_t) + buf->len);
}

type_buffer_t *buffer_create(env_t *env, int size);
type_buffer_t *buffer_slice(env_t *env, type_buffer_t *b, int start, int size);
int buffer_read_int(type_buffer_t *b, int off, int size, int be, int *v);
int buffer_write_int(type_buffer_t *b, int off, int size, int be, int num);

static inline
int   _buffer_size(type_buffer_t *b) {return b->len;}
static inline
void *_buffer_addr(type_buffer_t *b) {return b->buf;}

val_t buffer_native_create(env_t *env, int ac, val_t *av);
val_t buffer_native_write_int(env_t *env, int ac, val_t *av);
val_t buffer_native_write_uint(env_t *env, int ac, val_t *av);
val_t buffer_native_read_int(env_t *env, int ac, val_t *av);
val_t buffer_native_read_uint(env_t *env, int ac, val_t *av);
val_t buffer_native_slice(env_t *env, int ac, val_t *av);
val_t buffer_native_to_string(env_t *env, int ac, val_t *av);

void buffer_elem_get(val_t *self, int index, val_t *elem);

static inline
void *_val_buffer_addr(val_t *v) {
    return _buffer_addr((type_buffer_t *) val_2_intptr(v));
}

static inline
int _val_buffer_size(val_t *v) {
    return _buffer_size((type_buffer_t *) val_2_intptr(v));
}
*/

#endif /* __LANG_TYPE_BUFFER_INC__ */

